@extends('layouts.userctl')
@section('content')
    <style>
        .layui-form-checkbox span {
            width: 100px
        }
    </style>
    <div class="layui-card">
        <div class="layui-card-header layuiadmin-card-header-auto">
            <h2>用户【{{$user->name}}】分配角色</h2>
        </div>
        <div class="layui-card-body">
            <form class="layui-form" action="{{route('admin.user.assignUserrole',['id'=>$user->id])}}" method="post">
                {{csrf_field()}}
                {{method_field('put')}}
                <div class="layui-form-item">
                    <label for="" class="layui-form-label">角 色</label>
                    <div class="layui-input-block" style="width: 400px">
                        @forelse($roles as $role)
                            <dl class="cate-box">
                                <dt>
                                    <div class="cate-first">
                                        <input id="roles{{$role->id}}" type="checkbox" name="roles[]"
                                               value="{{$role->id}}" title="{{$role->role_name}}"
                                               lay-skin="primary" {{ isset($role->own)?'checked':''}} ></div>
                                </dt>
                            </dl>
                        @empty
                            <div style="text-align: center;padding:20px 0;">
                                无数据
                            </div>
                        @endforelse
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formDemo">确 认</button>
                        <a class="layui-btn layui-btn-normal" href="{{route('admin.user.userlist')}}">返 回</a>
                    </div>
                </div>
            </form>
        </div>
    </div>

@endsection
